package gaoji;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
/**
 * Remarks:
 * Class name :ThreadNew
 * Date :2023/2/16 17:02
 * Author:杨俊源
 */
public class ThreadNew {

    public static void main(String[] args){
        new MyThread1().start();

        new Thread(new MyThread2()).start();

        FutureTask<Integer> task = new FutureTask<Integer>(new MyThread3());
        new Thread(task).start();
        try {
            Integer num =  task.get();
            System.out.println(num);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ExecutionException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println("myThread1");
    }
}

class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("MyThread2");
    }
}

class MyThread3 implements Callable<Integer>{
    @Override
    public Integer call() throws Exception {
        System.out.println("MyThread3");
        return 100;
    }
}


